VERSION 0.6
FROM golang:1.19.3

build:
  WORKDIR /build
  RUN apt install -y git
  RUN apt install -y binutils
  COPY go.mod .
  COPY *.go .
  COPY impl impl
  COPY config config
  RUN go env -w GOPRIVATE="gitee.com,jihulab.com,atomgit.com"
  RUN go env -w GOPROXY="https://goproxy.cn,direct"
  RUN go mod tidy -compat=1.17
  RUN go build -o server
  RUN strip server
  SAVE ARTIFACT server

docker:
  FROM ubuntu
  ARG TAG="latest"
  WORKDIR /app
  RUN apt update
  RUN apt install -y ca-certificates
  COPY +build/server .
  COPY server.yaml .
  ENTRYPOINT /app/server /app/server.yaml
  SAVE IMAGE --push linksaas/tencent-storage:$TAG 
